<div class="page-toolbar">
    <div class="page-filter fr">
        <form class="layui-form layui-form-pane" action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">搜索</label>
            <div class="layui-input-inline">
                <input type="text" name="keyword" lay-verify="required" placeholder="请输入关键词搜索" autocomplete="off" class="layui-input">
            </div>
        </div>
        </form>
    </div>
    <div class="layui-btn-group fl">
        <a href="{:url('edit')}" class="layui-btn layui-btn-primary"><i class="aicon ai-tianjia"></i>添加</a>
        <a data-href="{:url('del')}" class="layui-btn layui-btn-primary j-page-btns confirm layui-icon layui-icon-close red">删除</a>
        <a data-href="{:url('status?table=qihan_article&val=1')}" class="layui-btn layui-btn-primary j-page-btns layui-icon layui-icon-play" data-table="dataTable">&nbsp;启用</a>
        <a data-href="{:url('status?table=qihan_article&val=0')}" class="layui-btn layui-btn-primary j-page-btns layui-icon layui-icon-pause" data-table="dataTable">&nbsp;禁用</a>
    </div>
</div>

{include file="admin@block/layui" /}

<table id="dataTable"></table>
<script type="text/html" title="状态模板" id="statusTpl">
    <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="启用|禁用" {{ d.status == 1 ? 'checked' : '' }} data-href="{:url('status')}?table=qihan_article&id={{ d.id }}">
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
        <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal">修改</a>
        <a href="{:url('del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>
</script>

<script type="text/javascript">
    layui.use(['table'], function() {
        var table = layui.table;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,limit: 20
            ,limits: [20, 50, 100]
            ,text: {
                none : '暂无相关数据'
            }
            ,cols: [[ //表头
                {type:'checkbox'},
                {field: 'id', title: '#', width: 30},
                {field: 'title', title: '标题'},
                // {field: 'subtitle', title: '子标题'},
                // {field: 'keywords', title: '关键词'},
                {field: 'author', title: '作者'},
                {field: 'source', title: '来源'},
                {field: 'category_id', title: '分类', templet: function(d){ return d.category.name;}},
                {field: 'pv', title: 'PV', width: 50},
                {field: 'img', title: '图片', width: 80, templet: function(d) {
                    return '<img src="' + d.img + '" width="60" height="60" class="fl">';
                }},
                {field: 'ctime', title: '创建时间'},
                {field: 'status', title: '状态', templet:'#statusTpl'},
                {title: '操作',templet: '#buttonTpl', width: 120},
            ]]
        });
    });
</script>
